﻿using System.Web.Mvc;
using MvcContrib.ActionResults;
using Peak.ApplicationServices;
using Peak.Resources;

namespace Peak.Web.Controllers.ErrorHandlers
{
  public class EntityNotFoundHandler : HandleErrorAttribute
  {
    public override void OnException(ExceptionContext filterContext)
    {
      if (filterContext.Exception is EntityNotFoundException)
      {
        filterContext.ExceptionHandled = true;
        filterContext.Result = new RedirectToRouteResult<BaseController>(f => f.MessageBox(Messages.EntityNotFoundOrNotEnoughPermissions));
      }
    }   
  }

}
